import {
  createApp,
  reactive,
  onMounted,
  onUnmounted,
  toRefs,
} from "../node_modules/vue/dist/vue.esm-browser.js";
function useMousePosition() {
  const position = reactive({
    x: 0,
    y: 0,
  });
  const update = (e) => {
    position.x = e.pageX;
    position.y = e.pageY;
  };
  onMounted(() => {
    window.addEventListener("mousemove", update);
  });
  onUnmounted(() => {
    window.addEventListener("mousemove", update);
  });
  return toRefs(position);
}
const app = createApp({
  setup() {
    const { x, y } = useMousePosition();
    return {
      x,
      y,
    };
  },
});
app.mount("#app");
